{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Full match: 123abc\n",
      "Group 1 (numbers): 123\n",
      "Group 2 (letters): abc\n"
     ]
    }
   ],
   "source": [
    "import re  \n",
    "  \n",
    "# 编译正则表达式 \n",
    "# 在正则表达式 r\"(\\d+)([A-Za-z]+)\" 中，有两个捕获组：\n",
    "# 第一个捕获组是 (\\d+)，它匹配一个或多个数字。\n",
    "# 第二个捕获组是 ([A-Za-z]+)，它匹配一个或多个字母。 \n",
    "pattern = re.compile(r\"(\\d+)([A-Za-z]+)\")  #正则表达式模式对象，通常是通过re.compile()函数创建的\n",
    "  \n",
    "# 查找匹配项  \n",
    "match = pattern.match(\"123abc\")  # 尝试从字符串的开始位置匹配正则表达式模式。\n",
    "if match:  \n",
    "    print(\"Full match:\", match.group())  # 输出：Full match: 123abc  \n",
    "    print(\"Group 1 (numbers):\", match.group(1))  # 输出：Group 1 (numbers): 123  \n",
    "    print(\"Group 2 (letters):\", match.group(2))  # 输出：Group 2 (letters): abc\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "pybroker",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
